package com.jeesite.modules.yl.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeesite.common.entity.Page;
import com.jeesite.common.service.CrudService;
import com.jeesite.modules.yl.entity.YlWorker;
import com.jeesite.modules.yl.dao.YlWorkerDao;

/**
 * 工人信息表Service
 * @author ccz
 * @version 2025-03-24
 */
@Service
public class YlWorkerService extends CrudService<YlWorkerDao, YlWorker> {
	@Autowired
	private YlWorkerDao ylWorkerDao;


	/**
	 * 获取单条数据
	 * @param ylWorker
	 * @return
	 */
	@Override
	public YlWorker get(YlWorker ylWorker) {
		return super.get(ylWorker);
	}
	
	/**
	 * 查询分页数据
	 * @param ylWorker 查询条件
	 * @param ylWorker.page 分页对象
	 * @return
	 */
	@Override
	public Page<YlWorker> findPage(YlWorker ylWorker) {
		return super.findPage(ylWorker);
	}
	
	/**
	 * 查询列表数据
	 * @param ylWorker
	 * @return
	 */
	@Override
	public List<YlWorker> findList(YlWorker ylWorker) {
		return super.findList(ylWorker);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param ylWorker
	 */
	@Override
	@Transactional
	public void save(YlWorker ylWorker) {
		super.save(ylWorker);
	}
	
	/**
	 * 更新状态
	 * @param ylWorker
	 */
	@Override
	@Transactional
	public void updateStatus(YlWorker ylWorker) {
		super.updateStatus(ylWorker);
	}
	
	/**
	 * 删除数据
	 * @param ylWorker
	 */
	@Override
	@Transactional
	public void delete(YlWorker ylWorker) {
		super.delete(ylWorker);
	}

    public String deleteList(List<String> list) {

		for (String s:list){
			ylWorkerDao.deleteList(s);
		}

		return "";
    }

	public String updateYlStatus(List<String> list) {
		if (list.size()==0){
			ylWorkerDao.updateYlStatus();
			return "已把全部数据状态修改为离职";
		}else {
			for (String s:list){
				ylWorkerDao.updateYlStatus1(s);
			}
			return "所选数据状态已经修改为在职";
		}
	}
}